package procsim;

import java.awt.*;

public class PaintPC extends PaintTab {
    public PaintPC(Paint parent) {
        super(parent);
        // Coordinates
        Design.one8.addCoords(this, 20, 50, 20, 65);
        Design.one8.addCoords(this, 20, 50, 101, 50);
        Design.one8.addCoords(this, 101, 50, 101, 60);
        Design.MDRout.addCoords(this, 45, 35, 117, 35);
        Design.MDRout.addCoords(this, 117, 35, 117, 60);
        Design.IR23_16.addCoords(this, 85, 20, 133, 20);
        Design.IR23_16.addCoords(this, 133, 20, 133, 60);
        Design.ADRTMPH.addCoords(this, 185, 20, 149, 20);
        Design.ADRTMPH.addCoords(this, 149, 20, 149, 60);
        Design.DISPH.addCoords(this, 215, 35, 165, 35);
        Design.DISPH.addCoords(this, 165, 35, 165, 60);
        Design.XHout.addCoords(this, 255, 50, 181, 50);
        Design.XHout.addCoords(this, 181, 50, 181, 60);
        Design.mxPC0.addCoords(this, 260, 90, 220, 90);
        Design.mxPC1.addCoords(this, 260, 110, 220, 110);
        Design.mxPC2.addCoords(this, 260, 130, 220, 130);
        Design.PCHMPout.addCoords(this, Design.PCHMP.getResCoords(30));
        Design.ldPCH.addCoords(this, Design.PCH.getLdCoords(35));
        Design.PCHout.addCoords(this, Design.PCH.getOutCoords(20));
        Design.PCHout.addCoords(this, 155, 270, 291, 270);
        Design.PCHout.addCoords(this, 291, 270, 291, 290);
        Design.zero8.addCoords(this, 320, 50, 320, 65);
        Design.zero8.addCoords(this, 320, 50, 401, 50);
        Design.zero8.addCoords(this, 401, 50, 401, 60);
        Design.MDRout.addCoords(this, 345, 35, 417, 35);
        Design.MDRout.addCoords(this, 417, 35, 417, 60);
        Design.IR15_8.addCoords(this, 385, 20, 433, 20);
        Design.IR15_8.addCoords(this, 433, 20, 433, 60);
        Design.ADRTMPL.addCoords(this, 485, 20, 449, 20);
        Design.ADRTMPL.addCoords(this, 449, 20, 449, 60);
        Design.DISPL.addCoords(this, 515, 35, 465, 35);
        Design.DISPL.addCoords(this, 465, 35, 465, 60);
        Design.XLout.addCoords(this, 555, 50, 481, 50);
        Design.XLout.addCoords(this, 481, 50, 481, 60);
        Design.mxPC0.addCoords(this, 560, 90, 520, 90);
        Design.mxPC1.addCoords(this, 560, 110, 520, 110);
        Design.mxPC2.addCoords(this, 560, 130, 520, 130);
        Design.PCLMPout.addCoords(this, Design.PCLMP.getResCoords(30));
        Design.ldPCL.addCoords(this, Design.PCL.getLdCoords(35));
        Design.PCLout.addCoords(this, Design.PCL.getOutCoords(20));
        Design.PCLout.addCoords(this, 455, 270, 319, 270);
        Design.PCLout.addCoords(this, 319, 270, 319, 290);
        Design.PCin.addCoords(this, Design.PC.getInCoords(15).verticalFlip());
        Design.ldPC.addCoords(this, Design.PC.getLdCoords(30));
        Design.incPC.addCoords(this, Design.PC.getIncCoords(30));
        Design.PCout.addCoords(this, Design.PC.getOutCoords(30));
        Design.ldADRTMP.addCoords(this, Design.ADRTMP.getLdCoords(55));
        Design.ADRTMPout.addCoords(this, Design.ADRTMP.getOutCoords(30));

        // Collections
        elements.add(Design.PC);
        elements.add(Design.PCH);
        elements.add(Design.PCL);
        elements.add(Design.ADRTMP);
        elements.add(Design.PCHMP);
        elements.add(Design.PCLMP);

        lines.add(Design.IR23_16);
        lines.add(Design.IR15_8);
        lines.add(Design.MDRout);
        lines.add(Design.PCout);
        lines.add(Design.one8);
        lines.add(Design.zero8);
        lines.add(Design.ADRTMPout);
        lines.add(Design.DISPH);
        lines.add(Design.DISPL);
        lines.add(Design.ADRTMPH);
        lines.add(Design.ADRTMPL);
        lines.add(Design.XHout);
        lines.add(Design.XLout);
        lines.add(Design.PCHMPout);
        lines.add(Design.PCLMPout);
        lines.add(Design.PCHout);
        lines.add(Design.PCLout);
        lines.add(Design.PCin);
        lines.add(Design.mxPC0);
        lines.add(Design.mxPC1);
        lines.add(Design.mxPC2);
        lines.add(Design.ldPCH);
        lines.add(Design.ldPCL);
        lines.add(Design.ldPC);
        lines.add(Design.incPC);
        lines.add(Design.ldADRTMP);
    }
    @Override
    public void paint(Graphics g){
        super.paint(g);
        Graphics2D gnew = (Graphics2D)g;
        Util.saveGraphics(gnew);
        gnew.setColor(Color.GRAY);
        gnew.setStroke(new BasicStroke(2));
        // grouping signals
        gnew.drawLine(285, 290, 285, 292); // |
        gnew.drawLine(285, 292, 303, 292); // -
        gnew.drawLine(303, 292, 305, 294); // \
        gnew.drawLine(305, 294, 307, 292); // /
        gnew.drawLine(307, 292, 325, 292); // -
        gnew.drawLine(325, 292, 325, 290); // |
        Util.restoreGraphics(gnew);
    }
}
